Skip to main content

fitPathToRect

Type​

handler

Summary​

Scales and translates a path to fit within a rectangle

Syntax​

fitPathToRect(<pTargetRect>,<xPath>,<pKeepAspect>)

Description​

Scales and transforms xPath so that it fits within pTargetRect. If pKeepAspect is true the aspect ratio will be kept.

Parameters​

NameTypeDescription

pTargetRect

The rectangle to fit the path within

xPath

The path to transform

pKeepAspect

If true the aspect ratio is kept

Examples​

use com.livecode.library.iconsvg

public handler OnPaint() returns nothing
-- get the 'shopping cart' icon from the icon library
variable tPathString as String
put iconSVGPathFromName("shopping cart") into tPathString

-- create the path
variable tPath as Path
put path tPathString into tPath

-- scale the path to fit within the bounds of the widget
fitPathToRect(my bounds, tPath, true)

-- fill the path
fill tPath on this canvas
end handler